package fenzhixianjie.onClass.exer02;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner read = new Scanner(System.in);
        int n = read.nextInt(), start = read.nextInt(), end = read.nextInt();
        int[] arr = new int[n + 1];
        for (int i = 0; i < n; i++) {
            arr[i + 1] = read.nextInt();
        }
        Queue<Integer> queue = new LinkedList<>();
        boolean[] flag = new boolean[n + 1];
        queue.offer(start);
        flag[start] = true;
        if (start == end) {
            System.out.println(0);
            return;
        }
        int step = 0;
        while (!queue.isEmpty()) {
            int size = queue.size();
            while (size > 0) {
                int top = queue.poll();
                int nextGap = arr[top];
                int nextUp = top + nextGap;
                int nextDown = top - nextGap;
                if (nextUp == end || nextDown == end) {
                    System.out.println(step + 1);
                    return;
                }
                if (nextUp <= n && nextUp >= 1 && !flag[nextUp]) {
                    queue.offer(nextUp);
                    flag[nextUp] = true;
                }
                if (nextDown <= n && nextDown >= 1 && !flag[nextDown]) {
                    queue.offer(nextDown);
                    flag[nextDown] = true;
                }
                size--;
            }
            step++;
        }
        System.out.println(-1);
    }
}
